@extends('layouts.mobile_main')

@section('title', '搜索')

@section('resources')
    @parent
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" href="{{ env('CSS_DOMAIN') }}/css/public.css?v={{env('CSS_VERSION')}}">
    <script src="{{env('JS_DOMAIN')}}/js/adaptation.js?v={{env('JS_VERSION')}}"></script>
    <style>
        .search_page input{width: 6rem;height: 0.7rem;border: 1px solid #9a54c6;border-radius: 0.2rem;margin: 0.3rem 0.5rem 0.3rem 0.8rem;background: url({{env('IMAGE_DOMAIN')}}images/search_p.png) 0.2rem 0.16rem no-repeat;background-size: 0.48rem;padding-left: 1rem;}
    </style>
@endsection

@section('content')
	<header class="search_page oh">
		<a class="fl" href="javascript:history.go(-1);"><img class="fl" src="{{env('IMAGE_DOMAIN')}}images/back_p.png?v={{env('IMAGE_VERSION')}}" alt=""></a>
		<input class="fl fz_40 search_contant" type="text" name="search" placeholder="输入商家、分类或商圈">
		<span class="fl fz_48 co_violet search_search" id="submit_search">搜索</span>
	</header>
	<section>
	    @if(count($selfsearch) > 0)
            <p class="search_pass fz_40 co_gray">你搜过的</p>
            <div class="pr" style="padding-bottom: 0.9rem;">
                <ul class="search_pass_list fz_40 oh pr">
                    @foreach($selfsearch as $list)
                        <li><a class="co_violet" href="/mobile/shop/search/result?search={{$list}}">{{$list}}</a></li>
                    @endforeach
                </ul>
                <a href="/mobile/shop/search/clear"><p class="search_clear fz_40 co_gray">清空历史</p></a>
            </div>
		@endif

		@if(count($globalsearch) > 0)
            <p class="search_pass fz_40 co_gray">大家都在搜</p>
            <ul class="search_all_list fz_40 co_gray oh">
                @foreach($globalsearch as $list)
                    <li><a class="co_gray" href="/mobile/shop/search/result?search={{$list}}">{{$list}}</a></li>
                @endforeach
            </ul>
		@endif
	</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        window.onresize=function(){
            pagesp();
        }
        $("#submit_search").click(function() {
            var search = $("input[name='search']").val();
            if(search == '') {
                alert("搜索内容不能为空");
            } else {
                window.location.href = '/mobile/shop/search/result?search=' + search;
            }
        });
    </script>
@endsection